<?php
  class Plugins_Hashtag extends model {
    
    function getformadd($productid="")
  {
  
  
  
  
  $echo=1;


      $code  = '<div class="wrpPlg clBg5 clBd2 bdFull">'."\n";
      $code .= '<div class="wrpOutAtcPlg">'."\n";
      $code .= '<div class="wrpAtcPlg">'."\n";
      $code .= '<span class="ico icoOri icoHshPlg"></span>'."\n";
      $code .= '<div class="spnAtcPlg clTxtW">'."\n";
      $code .= '<span class="txtAtcPlg fs03">Hashtag</span>'."\n";
      $code .= '</div>'."\n";
      $code .= '</div>'."\n";
      $code .= '</div>'."\n";
      $code .= '<div class="wrpTl">'."\n";
      $code .= '<div title="Close" class="btnIco closeTl clBd3 mgBtm10 deleterowbutton">'."\n";
      $code .= '<span class="ico icoCloseTl"></span>'."\n";
      $code .= '</div>'."\n";
      $code .= '</div>'."\n";
      $code .= '<form class="frmFrmPlg clTxt3 fs03">'."\n";
      $code .= '<fieldset class="wrpFrmPlg">'."\n";
      $code .= '<table class="tbGenInfo tbAddCtnt clTxt3 fs03">'."\n";
      $code .= '<tbody><tr>'."\n";
      $code .= '<th>HashTag</th>'."\n";
        $code .= '<td>'."\n";
        $code .= '<input type="text" name="detail[]" class="clBg5 clBd2 fs03 clTxt2">'."\n";
        $code .= '</td>'."\n";
        $code .= '</tr>'."\n";
        $code .= '<tr>'."\n";
        $code .= '<th>Amount</th>'."\n";
        $code .= '<td>'."\n";
        $code .= '<div class="reDesign">'."\n";
        
        $code .= '<select name="amount[]">'."\n";
        $code .= '<option value="9">9</option>'."\n";
        $code .= '<option value="18">18</option>'."\n";
        $code .= '<option value="27">27</option>'."\n";
        $code .= '</select>'."\n";
        
        $code .= '</div>'."\n";
        $code .= '</td>'."\n";
        $code .= '</tr>'."\n";
        $code .= '</tbody></table>'."\n";
        $code .= '</fieldset>'."\n";
        $code .= '</form>'."\n";
        $code .= '</div>';
  
  
  
  $arraydata['form']=addslashes(str_replace(array("\r", "", "\r"), '', $code));
 // $arraydata['js'][]=pluginjsinfo.'/image.js';
  //$arraydata['js'][]=baseinfo.'/js/jquery.Jcrop.min.js';
 // $arraydata['js'][]=baseinfo.'/js/jquery.iuploader-1.0.js';
  
  
      
  
  
  
  return $arraydata;
  
  
  
  
  
  
  
  }
   
   function saveplugin($arraydata,$productid,$plugreid)
  {
  
  
  $arraydata['productid']=$productid;
  $arraydata['plugreid']=$plugreid;
  

  
  
  
  $this->db->db_set($arraydata,'tb_plugins_hashtag');
  
  }
  
  function getformlanding($arraydata)
  {
  
// if($arraydata['simg']['newpath'])
// {
//$code  = '<div class="ldIt wrpImgLd clBg4 w640">'."";
//$code .= '<div class="icoDefLd">'."";
//$code .= '<span class="ico icoImgDefLd"></span>'."";
//$code .= '<span>Image</span>'."";
//$code .= '</div>'."";
//$code .= '<div class="wrpImgDesLd">'."";
//$code .= '<a href="javascript:void(0)"   class="galleryimage"><img  id="img-'.$arraydata['simgmid'].'" title="'.$arraydata['img']['newpath'].'" width="640" height="360"  alt="'.$arraydata['img']['width'].'|'.$arraydata['img']['height'].'" src="'.$arraydata['simg']['newpath'].'"></a>'."";
//$code .= '<div class="desImgLd clTxtW">'."";
//$code .= '<div onclick="openmaingallery('.$arraydata['simgmid'].')" class="ovlLd ovlImgLd w640">'."";
//$code .= '<p class="cutTxt">'.$arraydata['detail'].'</p>'."";
//$code .= '</div>'."";
//$code .= '</div>'."";
//$code .= '</div>'."";
//$code .= '</div>';
// }
$code="";

if(count($arraydata['product']))
{
$code='<div class="ldIt wrpHshLd clearfix" style="left: 0.5px;" id="pageRowSet-'.$arraydata['phashid'].'">';

    $arraysearch=explode("#",$arraydata['detail']);
    $strsearch="";
    if(count($arraysearch))
    {
     foreach($arraysearch as $valuesearch)
     {
     if($valuesearch)
     {
     $strsearch.='<a href="'.baseinfo.'/tag/'.$valuesearch.'" target="_blank">#'.$valuesearch.'</a> ';
     
     }
     
     
     }
    }

$code.='<div class="wrpHshTag">HashTag | '.$strsearch.'</div>';

foreach($arraydata['product'] as $valueproduct)
{
$code .= '<div onclick="linkto(\''.baseinfo.'/'.$valueproduct['link'].'/'.$valueproduct['productid'].'\')"  id="wrpInCell-'.$valueproduct['productid'].'" class="wrpInCellHvr wrpHshCell w238" style="width:193px;height:193px;margin:10px">'."\n";
$code .= '<div class="ovlCell w238"></div>'."\n";
$code .= '<img width="238" height="238" alt="img" src="'.$valueproduct['simg']['newpath'].'" class="imgCell w238">'."\n";
$code .= '<div class="ldTtlCell fs09 clTxtCell cutTxt">'.$valueproduct['title'].'</div>'."\n";
$code .= '<div class="authCell clearfix fs03 clTxtCell">'."\n";
$code .= '<img width="36" height="36" alt="User Image" class="imgUserCell" src="'.$valueproduct['userssimg']['newpath'].'">'."\n";
$code .= '<span class="authName cutTxt">'.$valueproduct['displayname'].'</span>'."\n";
//$code .= '<span class="proUser proCell clBgSp2 clTxtW fs01">Pro</span>'."\n";
$code .= '</div>'."\n";
$code .= '<div class="wrpLikeCell" onclick="favfunction('.$valueproduct['productid'].')">'."\n";
$code .= '<i class="ico icoUnLikeW"></i>'."\n";
$code .= '<span class="numLikeCell fs03 clTxtCell">'.$valueproduct['countlike'].'</span>'."\n";
$code .= '</div>'."\n";
$code .= '</div>';
}
$code.='</div>';

$code.='</div>';
$code.='<div class="wrpPageHshTag">';
// $retarr=array();
// $ret="<b>1</b>";
// $page=1;
// for( $i=1;$i<$arraydata['total_page']+1;$i++ ) {
//       if( $i == $page ) {
//           $retarr[]= " <b>$i</b> ";
//       } else {

//           $retarr[]= " <a href=\"javascript:void(0)\" onclick=\"loadhashtagpage('".$arraydata['detail']."',".$i.",".$arraydata['amount'].")\" >$i</a> ";
//       
//       }
//     } 

//if(count($retarr))
//{
//$ret=join("|",$retarr);
//}
$code.='<span class="pageHshTag pageSetHshTag-'.$arraydata['phashid'].'"></span>';

$code.='</div>';

$code.='<script>

$(function() {
setpagination(".pageSetHshTag-'.$arraydata['phashid'].'",'.$arraydata['total_page'].',1,"loadpagehashtag","'.$arraydata['detail'].'","'.$arraydata['amount'].'",'.$arraydata['phashid'].');
});

</script>';


}


$data['str']=$code;
$data['target']='secondtarget';


  
  return $data; 
  
  
  }
  
    function getplugin($plugreid)
  {
    $sql="select * from tb_plugins_hashtag where plugreid=".$plugreid;
    $arrayplugin=$this->db->db_set_1recordrow($sql);
 
    $arraysearch=explode("#",$arrayplugin['detail']);
    $arraytag=array();
    if(count($arraysearch))
    {
     foreach($arraysearch as $valuesearch)
     {
     if($valuesearch)
     {
     
     
     $sql='select * from tb_tag where tb_tag.`name` like "%'.trim($valuesearch).'%"';
     $tagset=$this->db->db_set_1recordrow($sql);
     if($tagset['tagid'])
     {
     $tagset['tagid']=intval($tagset['tagid']);
     $arraytag[]=$tagset;
     }
     
     }
     
     
     
     }
    
    }
    $arrayplugin['tag']=$arraytag;
    $arrayplugin['product']=$this->getproductbytagname($arrayplugin['detail'],0,$arrayplugin['amount']);
    $arrayplugin['countproduct']=$this->countproductbytagname($arrayplugin['detail']);
    $arrayplugin['total_page'] = ceil( (int)$arrayplugin['countproduct'] / (int)$arrayplugin['amount'] );

    
    


  
  return $arrayplugin;
  

  
  }
  
  }
?>
